﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="guaguaka.aspx.cs" Inherits="weikebuluo.web.wechat.guaguaka.guaguaka" %>


<!DOCTYPE html>
<html>
<head>
    <meta CHARSET="UTF-8">
    <title>刮刮乐</title>
    <link href="styles/layout.css" rel="stylesheet" type="text/css" />
    <style>

    
    
    </style>
    <script src="../../../scripts/JQuery.min.js" type="text/javascript"></script>
    <!--移动端版本兼容 -->
<script type="text/javascript">
    var phoneWidth = parseInt(window.screen.width);
    var phoneScale = phoneWidth / 640;
    var ua = navigator.userAgent;
    if (/Android (\d+\.\d+)/.test(ua)) {
        var version = parseFloat(RegExp.$1);
        if (version > 2.3) {
            document.write('<meta name="viewport" content="width=640, minimum-scale = ' + phoneScale + ', maximum-scale = ' + phoneScale + ', target-densitydpi=device-dpi">');
        } else {
            document.write('<meta name="viewport" content="width=640, target-densitydpi=device-dpi">');
        }
    } else {
        document.write('<meta name="viewport" content="width=640, user-scalable=no, target-densitydpi=device-dpi">');
    }
	</script>
<!--移动端版本兼容 end -->
    <script src="styles/wScratchPad.js?v=2" type="text/javascript"></script>
    <script src="../../../scripts/Su.common.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(document).ready(function() {
        var forward = '<%=forward %>';
        var first = '<%=award %>';
        var second = '<%=award2 %>';
        var times = '<%=times %>';
        
        if(times == '0'){
            //如果第一个未刮
        	$('.part1').after('<div id="wScratchPad1" ></div>');
            if(first == "1"){
        	    $('.part1').html('<img src="styles/weizhong.png" ><input id="first" type="hidden" value="1"/>');
            }else{

                switch(first){
                    case "一等奖":
                    $('.part1').html('<img src="styles/1.png" ><input id="first" type="hidden" value="'+first+'"/>');
                    break;
                    case "二等奖":
                    $('.part1').html('<img src="styles/2.png" ><input id="first" type="hidden" value="'+first+'"/>');
                    break;
                    case "三等奖":
                    $('.part1').html('<img src="styles/3.png" ><input id="first" type="hidden" value="'+first+'"/>');
                    break;
                    default:
                    $('.part1').html('<div style="margin-top: 111px;margin-left: 100px;font-size: 37px;"><span >恭喜您获得：'+first+'</span><input id="first" type="hidden" value="'+first+'"/></div>');
                    break;
                }
           
            }//中奖
        }else if(times == '1' || times == '2'){//如果第一个已刮
            
            if(first == "1"){
        	    $('.part1').after('<div id="wScratchPad1" style="visibility:hidden;"></div>');
                $('.part1').html('<img src="styles/weizhong.png" >');
            }else{
                switch(first){
                    case "一等奖":
                    $('.part1').html('<img src="styles/1.png" ><input id="first" type="hidden" value="'+first+'"/>');
                    break;
                    case "二等奖":
                    $('.part1').html('<img src="styles/2.png" ><input id="first" type="hidden" value="'+first+'"/>');
                    break;
                    case "三等奖":
                    $('.part1').html('<img src="styles/3.png" ><input id="first" type="hidden" value="'+first+'"/>');
                    break;
                    default:
                    $('.part1').html('<div style="margin-top: 111px;margin-left: 100px;font-size: 37px;"><span >恭喜您获得：'+first+'</span><input id="first" type="hidden" value="'+first+'"/></div>');
                    break;
                }
            }//中奖
        }
        
        
        //刮第一个时候
    	var sp1 = $("#wScratchPad1").wScratchPad({
            scratchUp: function(e, percent){
            	$.ajax({
                    url: "guaguaka.aspx?action=isor&uid="+getQueryString("uid")+"&wxid="+getQueryString("wxid")+"&hid="+getQueryString("hid"),
                    type: "post",
                    data:{first:$("#first").val()},
                    success: function (msg) {
                        if(msg == "200"){
                            alert("恭喜中奖，绑定vip卡，填写姓名和电话号码方便工作人员与您联系！");
                            location.href = "/web/wechat/vip/index.aspx?uid=" + getQueryString("uid") + "&wxid=" + getQueryString("wxid")+"&hid="+getQueryString("hid");
                        }
                    }
                });
            }

        });
        
        if(forward == "1"){
			$('.part2').after('<div id="wScratchPad3"><img src="styles/forward.png"></div>');
        }
        else if(forward == "3"){//已领奖
            $('#duijiang').append('<img alt="" src="styles/duijiang.png" width="">');
             if(second == "0"){
                $('.part2').html('<img src="styles/weizhong.png" >');//第二次卡未刮
            }else if(second == "1"){
                $('.part2').html('<img src="styles/weizhong.png" >');//第二次未中奖
            }else{
                $('.part2').html('<div style="margin-bottom: 129px;margin-left: 100px;font-size: 37px;"><span style="">恭喜您获得：'+second+'</span></div>');//中奖
            }

        }
        else{
//            if(times == "1"){
//            	$('.part2').after('<div id="wScratchPad2" style="display:inline-block;"></div>');
//            }else{
//            	$('.part2').after('<div id="wScratchPad2" style="visibility:hidden;"></div>');
//            }

            if(second == "0"){
                $('.part2').after('<div id="wScratchPad2" style="display:inline-block;"></div>');
                $('.part2').html('<img src="styles/weizhong.png" ><input id="second" type="hidden" value="1"/>');//第二次卡未刮
            }else if(second == "1"){
                $('.part2').html('<img src="styles/weizhong.png" >');//第二次未中奖
            }else{
                $('.part2').html('<div style="margin-bottom: 129px;margin-left: 100px;font-size: 37px;"><span style="">恭喜您获得：'+second+'</span><input id="second" type="hidden" value="'+second+'"/></div>');//中奖
            }
        }
        	var sp2 = $("#wScratchPad2").wScratchPad({
	            scratchUp: function(e, percent){
            	    $.ajax({
                        url: "guaguaka.aspx?action=isorno&uid="+getQueryString("uid")+"&wxid="+getQueryString("wxid")+"&hid="+getQueryString("hid"),
                        type: "post",
                        data:{second:$("#second").val()},
                        success: function (msg) {
                            if(msg == "200"){
                                
                            }
                        }
                    });
		        }
	        });
	        //设置刮奖区2图层
		$('#getPrice').click(function(){
			if(confirm('确认兑奖？')){
				$.ajax({
                        url: "guaguaka.aspx?action=duijiang&uid="+getQueryString("uid")+"&wxid="+getQueryString("wxid")+"&hid="+getQueryString("hid"),
                        type: "post",
                        success: function (msg) {
                            if(msg == "200"){
                                window.location.href = "guaguaka.aspx?uid="+getQueryString("uid")+"&wxid="+getQueryString("wxid")+"&hid="+getQueryString("hid");
                            }
                        }
                    });
			}
		});

	});
//TODO: CHANGE THE REDIRECT BLOW!
    var host = window.location.host;
    var link = window.location.href;
	var dataForWeixin={
	appId:	"",
	img:	"<%=logo %>", // get_post_weixin_thumb 为微信机器人高级版中的函数
	url:	link,
	title:	"刮刮卡好礼刮出来",
	desc:	"测试",
	fakeid:	"",
	};
	(function(){
		var onBridgeReady=function(){
			// 发送给好友; 
//			WeixinJSBridge.on('menu:share:appmessage', function(argv){
//				//alert(dataForWeixin.img);
//				WeixinJSBridge.invoke('sendAppMessage',{
//					"appid":		dataForWeixin.appId,
//					"img_url":		dataForWeixin.img,
//					"img_width":	"120",
//					"img_height":	"120",
//					"link":				dataForWeixin.url,
//					"desc":				dataForWeixin.desc,
//					"title":			dataForWeixin.title
//				}, function(res){
////  					var js = JSON.stringify(res);
////  					alert(js);exit();
//					if(res.err_msg == 'send_app_msg:confirm' || res.err_msg == 'send_app_msg:ok'){
//						$.post(
//				                "action.php", 
//				            	{
//					            	a: 2,
//					            	openId: "qqq",
//					            	eventId: "72"
//							    },
//			        			function (data, textStatus){
//				        			if(data == 1){
//							    		location.reload(true);
//				        			}else{
//										alert('网络不给力啊>.<');
//					        		}
//								},
//			        			"json");
//					}
//				});
//			});
			// 分享到朋友圈;
			WeixinJSBridge.on('menu:share:timeline', function(argv){
			   $.ajax({
                        url: "guaguaka.aspx?action=second&uid="+getQueryString("uid")+"&wxid="+getQueryString("wxid")+"&hid="+getQueryString("hid"),
                        type: "post",
                        success: function (msg) {
                            
                        }
                    });

				WeixinJSBridge.invoke('shareTimeline',{
				"img_url":dataForWeixin.img,
				"img_width":"120",
				"img_height":"120",
				"link":dataForWeixin.url,
				"desc":dataForWeixin.desc,
				"title":dataForWeixin.title
				}, function(res){
					if(res.err_msg == 'share_timeline:ok'){
						location.reload(true);
					}
				});
			});
			// 分享到微博;
			WeixinJSBridge.on('menu:share:weibo', function(argv){
				WeixinJSBridge.invoke('shareWeibo',{
				"content":dataForWeixin.title+' '+dataForWeixin.url,
				"url":dataForWeixin.url
				}, function(res){});
			});
		};
		if(document.addEventListener){
			document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
		}else if(document.attachEvent){
			document.attachEvent('WeixinJSBridgeReady'   , onBridgeReady);
			document.attachEvent('onWeixinJSBridgeReady' , onBridgeReady);
		}
	})();


    </script>
     
</head>
<body style="">
	<div class="warp">
    	<div class="wp">
            <div class="header"><img src="<%=logo %>" style="display:block;"></div>
                <div class="content">
                    <div class="part1"></div>
                    <div class="part2"></div>
                  <div style="position: relative;top: 130px;" id="duijiang"></div>
                </div>
          	<div class="footer"><img src="<%=footer %>" width="640"></div>
          	          	<br>
          	<br>
          	          	<p style="text-align: center;font-size:30px;">创意· 设计·技术支持 六层广告
</p>
          	
      </div>
    </div>

</body>
</html>